package com.ruoyi.electronicFence.controller;


import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.electronicFence.domain.TEfAreaApe;
import com.ruoyi.electronicFence.service.ITEfAreaApeService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.core.page.TableDataInfo;

import java.util.List;

/**
 * 围栏区域与监控点关联关系管理
 *
 * @author ruoyi
 * @date 2024-04-08
 */
@RestController
@RequestMapping("/electronicFence/ape")
public class TEfAreaApeController extends BaseController
{
    @Autowired
    private ITEfAreaApeService tEfAreaApeService;

    /**
     * 查询围栏区域与监控点关联关系列表
     */
//    @PreAuthorize("@ss.hasPermi('rsikManage:ape:list')")
    @GetMapping("/list")
    public TableDataInfo list(TEfAreaApe tEfAreaApe)
    {
        startPage();
        List<TEfAreaApe> list = tEfAreaApeService.selectTEfAreaApeList(tEfAreaApe);
        return getDataTable(list);
    }


    /**
     * 查询围栏区域与监控点关联关系列表
     */
//    @PreAuthorize("@ss.hasPermi('rsikManage:ape:list')")
    @GetMapping("/apeIds/list")
    public TableDataInfo AreaApelist(TEfAreaApe tEfAreaApe)
    {
        startPage();
        List<TEfAreaApe> list = tEfAreaApeService.selectTEfAreaApeList(tEfAreaApe);
        return getDataTable(list);
    }
    /**
     * 导出围栏区域与监控点关联关系列表
     */
//    @PreAuthorize("@ss.hasPermi('rsikManage:ape:export')")
    @Log(title = "围栏区域与监控点关联关系", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TEfAreaApe tEfAreaApe)
    {
        List<TEfAreaApe> list = tEfAreaApeService.selectTEfAreaApeList(tEfAreaApe);
        ExcelUtil<TEfAreaApe> util = new ExcelUtil<TEfAreaApe>(TEfAreaApe.class);
        util.exportExcel(response, list, "围栏区域与监控点关联关系数据");
    }

    /**
     * 获取围栏区域与监控点关联关系详细信息
     */
//    @PreAuthorize("@ss.hasPermi('rsikManage:ape:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tEfAreaApeService.selectTEfAreaApeById(id));
    }

    /**
     * 新增围栏区域与监控点关联关系
     */
//    @PreAuthorize("@ss.hasPermi('rsikManage:ape:add')")
    @Log(title = "围栏区域与监控点关联关系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TEfAreaApe tEfAreaApe)
    {
        return toAjax(tEfAreaApeService.insertTEfAreaApe(tEfAreaApe));
    }

    /**
     * 修改围栏区域与监控点关联关系
     */
//    @PreAuthorize("@ss.hasPermi('rsikManage:ape:edit')")
    @Log(title = "围栏区域与监控点关联关系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TEfAreaApe tEfAreaApe)
    {
        if (tEfAreaApe.getParamId()!=null)
        tEfAreaApe.setId(tEfAreaApe.getParamId());
        return toAjax(tEfAreaApeService.updateTEfAreaApe(tEfAreaApe));
    }

    /**
     * 删除围栏区域与监控点关联关系
     */
//    @PreAuthorize("@ss.hasPermi('rsikManage:ape:remove')")
    @Log(title = "围栏区域与监控点关联关系", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tEfAreaApeService.deleteTEfAreaApeByIds(ids));
    }
}
